import request from '@/utils/request'

export function getAttrGroupWithAttr(catalogId) {
  return request({
    url: `/product/attrGroup/getGroupWithAttr/${catalogId}`,
    method: 'get',
  })
}

export function findAttrGroup(params) {
  return request({
    url: '/product/attrGroup/find',
    method: 'get',
    params
  })
}

export function listAllAttrGroup(params) {
  return request({
    url: '/product/attrGroup/list',
    method: 'get',
    params
  })
}

export function getAttrGroup(id) {
  return request({
    url: '/product/attrGroup/getById',
    method: 'get',
    params: {id}
  })
}

export function getAttrGroupWithAttrByCategoryId(categoryId) {
  return request({
    url: `/product/attrGroup/${categoryId}/withattr`,
    method: 'get'
  })
}


export function saveAttrGroup(data) {
  return request({
    url: '/product/attrGroup/save',
    method: 'post',
    data
  })
}

export function updateAttrGroup(data) {
  return request({
    url: '/product/attrGroup/update',
    method: 'post',
    data
  })
}

export function deleteAttrGroup(ids) {
  return request({
    url: '/product/attrGroup/delete',
    method: 'post',
    data: ids
  })
}


export function deleteAttrAttrGroupRelation(data) {
  return request({
    url: '/product/attrGroup/attr/relation/delete',
    method: 'post',
    data
  })
}

export function addAttrAttrGroupRelation(data) {
  return request({
    url: '/product/attrGroup/attr/relation',
    method: 'post',
    data
  })
}

export function getRelationByGroupId(groupId) {
  return request({
    url: `/product/attrGroup/relationList/${groupId}`,
    method: 'get'
  })
}

export function noRelationByGroupId(params) {
  return request({
    url: `/product/attrGroup/uncorrelatedAttr/relation`,
    method: 'get',
    params
  })
}
